//
// Created by 77873 on 2020/10/10 0010.
//

#ifndef FFMPEGVIDEOPLAYER_CALLBACKTOJAVA_H
#define FFMPEGVIDEOPLAYER_CALLBACKTOJAVA_H


#include <cwchar>
#include "AndroidLog.h"
#include "jni.h"

//主线程
#define  MAIN_THREAD 0
//子线程
#define  CHILD_THREAD 1

/**
 * 此类用于c++层回调 到java层的方法
 */
class CallBackToJava {

public:
    JavaVM *javaVM = NULL;

    JNIEnv *jniEnv = NULL;

    jobject jobj;


    jmethodID jmid_parpared;
    jmethodID jmid_error;
    jmethodID jmid_load;
    jmethodID jmid_complete;
    jmethodID jmid_videoTimeInfo;

    jmethodID jmid_renderYuv;
    jmethodID jmid_isSupportMediaCodec;
    jmethodID jmid_initMediaCodec;

    jmethodID jmid_decodecAvpacket;

public:
    CallBackToJava(JavaVM *vm, JNIEnv *evn, jobject *obj);
    ~CallBackToJava();

    void OnCallParpared(int type);

    void OnCallError(int type,int code,char *msg);

    void onCallLoad(int type, bool isLoad);

    void OnCallComplete(int type);

    void onCallRenderYuv(int width,int height,uint8_t *fy,uint8_t *fu,uint8_t *fv);

    void onCallTimeInfo(int type,int currentTime, int totalTime);

    bool onCllIsSupportMediaCodec(const char *codecName);

    void onCallInitMediaCodec(const char *codecName, int width,int height,int csd0_size,int csd1_size,uint8_t *csd_0,uint8_t *csd_1);


    void decodecAvpacket(int size, uint8_t *data);
};


#endif //FFMPEGVIDEOPLAYER_CALLBACKTOJAVA_H
